package com.glacier.framework.boot.rest.controller;

import com.glacier.framework.component.exception.BizException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * date 2023-12-30 21:02
 *
 * @author glacier
 * @version 1.0
 */
@RestController
@RequestMapping("/ex")
public class ExceptionController {

    /**
     * @param id
     * @return
     */
    @GetMapping("/exception1")
    public String exception1(String id) throws IllegalAccessException {
        throw new IllegalAccessException("exception1");
    }

    /**
     * @param id
     * @return
     */
    @GetMapping("/exception2")
    public String exception2(String id) {
        throw new NullPointerException("exception2");
    }


    /**
     * @param id
     * @return
     */
    @GetMapping("/exception3")
    public String exception3(String id) {
        throw new BizException("exception3");
    }

    /**
     * @param id
     * @return
     */
    @GetMapping("/exception4")
    public String exception4(String id) throws Exception {
        throw new Exception("exception4");
    }

    /**
     * @param id
     * @return
     */
    @PostMapping("/exception5")
    public String exception5(String id) {
        return "exception5";
    }

    /**
     * @param id
     * @return
     */
    @GetMapping("/exception6")
    public String exception6(String id) {
        int i = 1 / 0;
        return "exception6";
    }
}
